/*
 * @Author: kadu
 * @Date: 2021-06-26 03:01:46
 * @LastEditTime: 2021-06-26 12:41:46
 * @LastEditors: Please set LastEditors
 * @Description: 表配置的实例体
 */

export class ConfigEntity {

    private table: { [key in string | number]: any };

    constructor(table: any) {
        this.table = table;
    }

    /**
     * 通关id获取配置
     * @param id 
     * @returns 
     */
    public Get(id: number | string): any {
        return this.table[id];
    }

    /**
     * 通关key和value获取配置
     * @param key 数据结构上的字段名字
     * @param value 字段对应的值
     * @returns 
     */
    public GetEx(key: string, value: any): any {
        for (let k in this.table) {
            let item = this.table[k];
            if (item[key] == value) {
                return item;
            }
        }
        return null;
    }

    /**
     * 获取整个表
     * @returns 
     */
    public GetTable(): { [key in string | number]: any } {
        return this.table;
    }
}